/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.za.cput.designpatterns.behavioral.visitor;

import java.util.List;

/**
 *
 * @author user
 */
public class SumVisitor implements NumberVisitor  {
    
    @Override
    public void visit(TwoElement twoElement){
        int sum = twoElement.a + twoElement.b;
        System.out.println(twoElement.a+" + "+ twoElement.b +" = "+sum);
    }
    
    @Override
    public void visit(ThreeElement threElement){
        int sum = threElement.a + threElement.b + threElement.c;
        System.out.println(threElement.a+" + "+ threElement.b+"+"+threElement.c +"= "+sum);
    }
    
    @Override
    public void visit(List<NumberElement> elementList){
        for(NumberElement ne : elementList){
            ne.accept(this);
        }
    }
}
